package br.edu.ufcg.greengrid.model.job;


public class JobWithCheckpoint extends Job {

	private Long operationsPerTime;
	
	public JobWithCheckpoint(long runtime) {
		
		super(runtime);
	}

	public JobWithCheckpoint(long submitTime, long runtime) {
		
		super(submitTime, runtime);
	}

	public JobWithCheckpoint(long submitTime, long runtime, long timeToOperationsFactor) {
		
		super(submitTime, runtime, timeToOperationsFactor);
	}
	
	public JobWithCheckpoint(String id, long submitTime, long runtime, long timeToOperationsFactor) {
		
		super(id, submitTime, runtime, timeToOperationsFactor);
	}
	
	public void clear() {
		//Do nothing. Checkpoint is ON.
	}
	
	public void normalizeRuntime(long operationsPerTime) {
		
		if(this.operationsPerTime == null){
			operationsPerTime = this.timeToOperationsFactor;
			normalizeRuntime(operationsPerTime, this.runtime);
			this.operationsPerTime = operationsPerTime;
		} else {
			long runtime = (long)Math.ceil(1.0 * this.runtimeCounter * this.operationsPerTime / this.timeToOperationsFactor);
			normalizeRuntime(operationsPerTime, runtime);
			this.operationsPerTime = operationsPerTime;
		}
	}
	
}
